// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=1045

//#define COMPILE
#ifdef COMPILE

#include <fstream>

using namespace std;

int n;


void input() {
    ifstream in("input.txt");
    in >> n;
    
    in.close();
}

void output() {
    ofstream out("output.txt");
    
    for (int i = 1; i <= n; i++) {
        int sum = 0;
        int j = i;
        while (j > 0) {
            int k = j % 10;
            sum += k * k * k;
            j /= 10;
        }
        if (sum == i)
            out << i << endl;
    }
    
    out.close();
}

int main() {
    input();
    
    
    output();
    return 0;
}


#endif
